﻿Ext.extend(Ext.form.Action.Load, Ext.form.Action, {
	// private
	type: 'load',

	// private
	run: function () {
		Ext.Ajax.request(Ext.apply(this.createCallback(this.options), {
			method: this.getMethod(),
			url: this.getUrl(false),
			headers: this.options.headers,
			params: this.getParams()
		}));
	},

	// private
	success: function (response) {
		var result = this.processResponse(response);
		if (result === true || !result.success || !result.data) {
			this.failureType = Ext.form.Action.LOAD_FAILURE;
			this.form.afterAction(this, false);
			return;
		}
		this.form.beforeSetafterLoad(result.data); //zhangxian添加
		this.form.clearInvalid();
		this.form.setValues(result.data);
		this.form.afterAction(this, true);
	},

	// private
	handleResponse: function (response) {
		if (this.form.reader) {
			var rs = this.form.reader.read(response);
			var data = rs.records && rs.records[0]
							? rs.records[0].data
							: null;
			return {
				success: rs.success,
				data: data
			};
		}
		return Ext.decode(response.responseText);
	}
});
Ext.override(Ext.form.BasicForm, {
	beforeSetafterLoad: function (data) {
		this.fireEvent('beforeSetafterLoad', data)
	}
});